package qlsl.androiddesign.http.service.subservice;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import qlsl.androiddesign.constant.WhatConstant;
import qlsl.androiddesign.handler.subhandler.HttpHandler;
import qlsl.androiddesign.http.HttpListener;
import qlsl.androiddesign.http.service.baseservice.BaseService;
import qlsl.androiddesign.http.xutils.HttpProtocol;
import qlsl.androiddesign.thread.HandlerThread;
import qlsl.androiddesign.util.commonutil.Log;
import qlsl.androiddesign.view.baseview.FunctionView;

/**
 * **模块 <br/>
 * 
 */
public class TestService extends BaseService {

	private static String className = getClassName(TestService.class);

	public static void queryGroupList(final FunctionView<?> functionView,
			final HttpListener listener) {
		final HttpHandler handler = getHandler(functionView, listener,
				className, "queryGroupList");
		new HandlerThread(className, "queryGroupList") {
			public void run() {
				HttpProtocol protocol = new HttpProtocol();
				try {
					JSONObject jo = protocol.setMethod("getgrouplist").post();
					if (isDataInvalid(jo, handler, protocol)) {
						return;
					}
					Log.e("zcj", jo);

					Object object = JSON.toJavaObject(jo, Object.class);

					handler.sendMessage(protocol,
							WhatConstant.WHAT_NET_DATA_SUCCESS, object);
				} catch (Exception e) {
					e.printStackTrace();
					handler.sendMessage(protocol, WhatConstant.WHAT_EXCEPITON,
							e);
				}
			};
		}.start();
	}
}
